﻿Imports System.Runtime.CompilerServices


Namespace OfflineLibrary_WPF
	Module Helpers
		'http://stackoverflow.com/a/14976878/271351
		Public Function GetEnum(Of T)() As IEnumerable(Of Object)
			Dim type = GetType(T)
			Dim names = [Enum].GetNames(type)
			Dim values = [Enum].GetValues(type)
			Dim pairs = Enumerable.Range(0, names.Length).[Select](Function(i) New With {
			 .Name = names.GetValue(i),
			 .Value = values.GetValue(i)
			}).OrderBy(Function(pair) pair.Name)
			Return pairs
		End Function

		<Extension()>
		Public Sub AddOnUI(Of T)(collection As ICollection(Of T), item As T)
			Dim addMethod As Action(Of T) = AddressOf collection.Add
			Application.Current.Dispatcher.BeginInvoke(addMethod, item)
		End Sub


	End Module

End Namespace
